/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

/**
 *
 * @author daz
 */
import entity.Professor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import manager.ProfessorManager;
import manager.StudentManager;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import util.Debug;

public class ProfessorController extends SimpleFormController {

    private ProfessorManager professorManager;

    public ProfessorController() {
        setCommandClass(Professor.class);
        setCommandName("professorForm");
    }

    public void setProfessorManager(ProfessorManager professorManager) {
        this.professorManager = professorManager;
    }

    public ProfessorManager getProfessorManager() {
        return professorManager;
    }

    @Override
    protected ModelAndView onSubmit(HttpServletRequest request,
            HttpServletResponse response, Object command, BindException errors)
            throws Exception {
        Professor professor = (Professor) command;
        professorManager.insertNewProfessor(professor);
        return new ModelAndView("ProfessorSucess", "professor", professor);

    }
}
